// TODO  不完整版  用户分组尚未解耦

/*!
 * 文章选择的模块
 * @author Sherlock 
 * 本模块需要手动载入初始化
 */

require( './style.less' );
define( [
  'jquery',
  'require',
  'message',
  'api',
  'constants',
  'bigwe_utils',
  'bootstrap'
], function( $, require ) {
  return function( obj, articleChooseCallback ) {
    var ShowTitleMessage = require( 'message' );
    var showTime = ShowTitleMessage.showTime;
    var apisCommon = require( 'api' );
    var apis = apisCommon.CHOOSEARTICLE;
    var bu = require( 'bigwe_utils' );
    var c = require( 'constants' );
    var that = $( '#util_article_choose' );
    // 推荐的查询参数
    var articleOptions = [ {
      param: {
        p: 1,
        cc: obj.userTag || '',
        l: 12,
        type: 'art'
      },
      setAttrbute: function( options, fn ) {
        $.extend( this.param, options );
        ArticleChooseHtmlBuild.recommend( this.param, fn );
      }
    }, {
      param: {
        page_num: 1,
        group_select: '',
        select_type: '',
        keyword: ''
      },
      setAttrbute: function( options, fn ) {
        $.extend( this.param, options );
        ArticleChooseHtmlBuild.myResourceDetailsHtml( this.param, fn );
      }
    }, {
      param: {
        p: 1,
        rt: 'collectArt',
        key: '',
        limit: 12
      },
      setAttrbute: function( options, fn ) {
        $.extend( this.param, options );
        ArticleChooseHtmlBuild.myCollection( this.param, fn );
      }
    } ];


    var ArticleChooseHtmlBuild = {
      options: {
        isloaded: false, // 是否加载过了
        tabIndex: 0, //标签页区分
        groupName: '', // 当前查询自定义分组名
        copyright: '', // 当前查询原创或收藏
        searchKeyword: '', // 搜索关键字
        resourceTagID: '000', // 当前查询素材库的类型
        resourcePageNo: 1, // 素材库当前页码
        myResourceNoData: false, // 我的素材没有跟多数据了
        myResourcePageNo: 1, // 我的素材当前页码
        resourceIsScrollLoad: false, // 素材库是否在滚屏加载
        myResourceIsScrollLoad: false // 我的素材是否在滚屏加载
      },
      optionsSetup: function( option ) {
        $.extend( this.options, option );
        return this;
      },
      groupBtnHtml: function( groupName ) {
        return groupName ? '<button type="button" groupid="' + groupName.id + '">' + groupName.category_name + '</button>' : '';
      },
      resourceDetailsHtml: function( tagID ) {
        if ( !tagID ) return;
        var $this = this;
        this.options.resourceTagID = tagID;
        $( '.resource>.spinner', that ).show();
        $.ajax( {
          type: 'get',
          url: apis.GET_ARTICLE_LISTS,
          data: {
            'tagIds': tagID,
            'pageNum': this.options.resourcePageNo,
            'keyword': $this.options.searchKeyword
          },
          success: function( retdata ) {
            if ( !retdata ) {
              ShowTitleMessage.showWarning( '没有更多数据了:-(', showTime );
              return;
            }
            var jsonData = retdata;
            for ( key in jsonData ) {
              var obj = jsonData[ key ];
              var img_url = '/refer?url=' + obj.cdn_url;
              $( '.resource>.res-det', that ).append( '<div article-ID="' + obj.article_id + '">' +
                '<span>' + obj.create_time + '</span>' +
                '<span>' + obj.title + '</span>' +
                '<img width="260" height="143" onerror="this.src=\"' + c.resPath + '/images/wuyulantu.png\";" src="' + img_url + '">' +
                '<span>' + ( obj.author || '' ) + '</span>' +
                '<div class="filter"><div><p>' +
                '<a href="/article?p=' + obj.article_id + '" target="_blank" class="prevArticle"><span class="iconfont icon-yulan"></span>&nbsp;<span>预览</span></a>&emsp;&emsp;' +
                '<span class="iconfont icon-doSelect">&nbsp;<span>选择</span></span>' +
                '</p></div></div><div class="glyphicon glyphicon-ok selected"></div></div>' );
            }
          },
          complete: function() {
            $( '.resource>.spinner', that ).hide();
            $this.options.resourceIsScrollLoad = false;
          },
          dataType: 'json'
        } );
        this.options.resourcePageNo++;
        return this;
      },
      myResourceDetailsHtml: function( param, fn ) {
        var me = $( '.my-resource', that );
        me.find( '>.spinner' ).show();
        $.ajax( {
          type: 'get',
          url: apis.GET_MATERIAL_LIST,
          data: param,
          success: function( data ) {
            $( '.my-resource>.res-det', that ).empty();
            if ( !data.data.articles || data.data.articles.length == 0 ) {
              ShowTitleMessage.showWarning( "没有数据了:-(", showTime );
              $( '.maxPage,.current_page', me ).text( 1 );
              $( '.pageControl .next,.pageControl .prev', me ).prop( 'disabled', 'disabled' );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
              return;
            }
            var jsonData = data.data.articles;
            for ( key in jsonData ) {
              var obj = jsonData[ key ];
              $( '.my-resource>.res-det', that ).append( '<div article-ID="' + obj.article_id + '">' +
                '<span>' + obj.create_time + '</span>' +
                '<span>' + obj.title + '</span>' +
                '<img class="cover" width="260" height="143" onerror="this.src=\'' + c.resPath + '/images/wuyulantu.png\';" src="' + bu.wechartImgCheck( obj.image ) + '">' +
                '<span>' + ( obj.author || '' ) + '</span>' +
                '<div class="filter"><div><p>' +
                '<a href="/article?p=' + obj.article_id +
                '" target="_blank" class="prevArticle"><span class="iconfont icon-yulan"></span>&nbsp;<span>预览</span></a>&emsp;&emsp;' +
                '<span class="chooseThis"><span class="iconfont icon-doSelect"></span>&nbsp;<span>选择</span></span>' +
                '</p></div></div><div class="glyphicon glyphicon-ok selected"></div></div>' );
            }
            $( '.current_page', me ).text( param.page_num );
            $( '.maxPage', me ).text( data.data.total_page || 1 );
            if ( data.data.total_page * 1 === 1 ) {
              $( '.pageControl .next', me ).prop( 'disabled', 'disabled' );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
            } else if ( data.data.total_page > 1 ) {
              $( '.pageControl', me ).css( 'visibility', 'visible' );
            }
            if ( param.p != data.data.total_page ) {
              $( '.pageControl .next', me ).removeAttr( 'disabled' );
            }

            if ( fn ) {
              fn( data );
            }
          },
          complete: function() {
            me.find( '>.spinner' ).hide();
          },
          dataType: 'json'
        } );

        return this;
      },
      articleGroup: function() {
        $.ajax( {
          type: 'post',
          url: apisCommon.COMMON.GET_MEDIA,
          data: {
            rt: 'article'
          },
          success: function( data ) {
            if ( !data.ret ) {
              for ( i in data.data ) {
                var group = data.data[ i ];
                var html = '<button  type="button" groupid="' + group.id + '">' + group.group_name + '</button>';
                $( '#my-resource .my-group', that ).append( html );
              }

              function myGroupFun() {
                if ( $( '#my-resource .my-group', that ).height() > 31 ) {
                  $( '#my-resource .more', that ).show();
                }
              }
              if ( $( '.my-resource', that ).css( 'display' ) != 'none' ) {
                myGroupFun();
              } else {
                $( '.my-resource', that ).show();
                myGroupFun();
                $( '.my-resource', that ).hide();
              }

            }
          },
          complete: function() {
            $( '#my-resource .spinner', that ).hide();
          }
        } );
      },
      recommend: function( param, fn ) {
        var me = $( '.recommend', that );
        $( '.spinner', me ).show();
        $.ajax( {
          type: 'post',
          url: apisCommon.SEARCH.SEARCH_LIST,
          data: param,
          success: function( data ) {
            data = typeof data === 'string' ? $.parseJSON( data ) : data;
            $( '.recommend>.res-det', that ).empty();

            if ( data.ret ) {
              ShowTitleMessage.showWarning( data.msg || '发生了一些错误', showTime );
              return;
            }
            data = data.data;
            if ( !data.data.articles || !data.data.articles.length ) {
              ShowTitleMessage.showWarning( "没有数据了:-(", showTime );
              $( '.maxPage,.current_page', me ).text( 1 );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
              return;
            }

            var totalPage = data.total_pages >= 5 ? 5 : ( data.total_pages || 1 );
            for ( i in data.data.articles ) {
              var article = data.data.articles[ i ];
              $( '.recommend>.res-det', that ).append( '<div article-ID="' + article.cd + '">' +
                '<span>' + ( new Date( article.publish_time_millis * 1 ) ).format( 'yyyy-MM-dd hh:mm' ) + '</span>' +
                '<span>' + article.title + '</span>' +
                '<img class="cover" width="260" height="143" onerror="this.src=\'' + c.resPath + '/images/wuyulantu.png\';" src="' + bu.wechartImgCheck( article.cover_img_url ) + '">' +
                '<span>' + ( article.publisher || '' ) + '</span>' +
                '<div class="filter"><div><p>' +
                '<a href="/article?p=' + article.cd + '" target="_blank" class="prevArticle"><span class="iconfont icon-yulan"></span>&nbsp;<span>预览</span></a>&emsp;&emsp;' +
                '<span class="chooseThis"><span class="iconfont icon-doSelect"></span>&nbsp;<span>选择</span></span>' +
                '</p></div></div><div class="glyphicon glyphicon-ok selected"></div></div>' );
            }
            $( '.current_page', me ).text( param.p );
            $( '.maxPage', me ).text( totalPage );

            if ( totalPage === 1 ) {
              $( '.pageControl .next', me ).prop( 'disabled', 'disabled' );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
            } else if ( totalPage > 1 ) {
              $( '.pageControl', me ).css( 'visibility', 'visible' );
            }
            if ( param.p != totalPage ) {
              $( '.pageControl .next', me ).removeAttr( 'disabled' );
            }
            if ( fn ) {
              fn( data );
            }
          },
          complete: function() {
            $( '.spinner', me ).hide();
          }
        } );
      },
      collectionGroup: function() {
        $.ajax( {
          type: 'post',
          url: apisCommon.COMMON.GET_MEDIA,
          data: {
            rt: 'collectArt'
          },
          success: function( data ) {
            if ( !data.ret ) {
              for ( i in data.data ) {
                var group = data.data[ i ];
                var html = '<button  type="button" groupid="' + group.id + '">' + group.group_name + '</button>';
                $( '#my-collection .my-group', that ).append( html );
              }

              function myGroupFun() {
                if ( $( '#my-collection .my-group', that ).height() > 31 ) {
                  $( '#my-collection .more', that ).show();
                }
              }
              if ( $( '.my-collection', that ).css( 'display' ) != 'none' ) {
                myGroupFun();
              } else {
                $( '.my-collection', that ).show();
                myGroupFun();
                $( '.my-collection', that ).hide();
              }

            }
          },
          complete: function() {
            $( '#my-collection .spinner', that ).hide();
          }
        } );
      },
      myCollection: function( param, fn ) {
        var me = $( '.my-collection', that );
        me.find( '>.spinner' ).show();
        $.ajax( {
          type: 'post',
          url: apisCommon.MYCOLLECTION.COLLECT_ART_LS,
          data: param,
          success: function( data ) {
            data = typeof data === 'string' ? $.parseJSON( data ) : data;
            $( '.my-collection>.res-det', that ).empty();

            if ( !data.data || !data.data.length || data.ret === 70006 ) {
              ShowTitleMessage.showWarning( "没有数据了:-(", showTime );
              $( '.maxPage', me ).text( 1 );
              $( '.current_page', me ).text( 1 );
              $( '.pageControl .next,.pageControl .prev', me ).prop( 'disabled', 'disabled' );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
              return;
            }
            if ( data.ret ) {
              ShowTitleMessage.showWarning( data.msg || '发生了一些错误', showTime );
              return;
            }
            for ( var i in data.data ) {
              var article = data.data[ i ];
              $( '.my-collection>.res-det', that ).append( '<div article-ID="' + article.cd + '">' +
                '<span>' + ( new Date( article.publish_time_millis * 1 ) ).format( 'yyyy-MM-dd hh:mm' ) + '</span>' +
                '<span>' + article.title + '</span>' +
                '<img class="cover" width="260" height="143" onerror="this.src=\'' + c.resPath + '/images/wuyulantu.png\';" src="' + bu.wechartImgCheck( article.cover_img_url ) + '">' +
                '<span>' + ( article.publisher || '' ) + '</span>' +
                '<div class="filter"><div><p>' +
                '<a href="/article?p=' + article.cd + '" target="_blank" class="prevArticle"><span class="iconfont icon-yulan"></span>&nbsp;<span>预览</span></a>&emsp;&emsp;' +
                '<span class="chooseThis"><span class="iconfont icon-doSelect"></span>&nbsp;<span>选择</span></span>' +
                '</p></div></div><div class="glyphicon glyphicon-ok selected"></div></div>' );
            }
            var totalPage = parseInt( data.total / param.limit );
            if ( data.total % param.limit > 0 ) {
              ++totalPage;
            }
            $( '.current_page', me ).text( param.p );
            $( '.maxPage', me ).text( totalPage );
            if ( totalPage === 1 ) {
              $( '.pageControl .next', me ).prop( 'disabled', 'disabled' );
              $( '.pageControl', me ).css( 'visibility', 'hidden' );
            } else if ( totalPage > 1 ) {
              $( '.pageControl', me ).css( 'visibility', 'visible' );
            }
            if ( param.p != totalPage ) {
              $( '.pageControl .next', me ).removeAttr( 'disabled' );
            }
            if ( fn ) {
              fn( data );
            }
          },
          complete: function() {
            me.find( '>.spinner' ).hide();
          }
        } );
      },
      resourceEmpty: function() {
        $( '.resource>.res-det', that ).empty();
        return this;
      },
      myResourceEmpty: function() {
        $( '.my-resource>.res-det', that ).empty();
        return this;
      },
      showMoreBtn: function( parent, self ) {
        var $obj = parent;
        if ( $obj.height() < 60 ) {
          $obj.transition( {
            'height': $( '.height-cacu', $obj ).height()
          } );
          $( '.glyphicon', self ).transition( {
            rotate: 180
          } );
          $( self ).attr( 'status', 1 );
        } else {
          $obj.transition( {
            'height': 30
          } );
          $( '.glyphicon', self ).transition( {
            rotate: 0
          } );
          $( self ).attr( 'status', 0 );
        }
      },
      userCategoryAndGroup: function( jsonObj ) {
        var $display = $( '.resource>#resource .spinner, .my-resource>#my-resource>.spinner', that );
        var tagID = jsonObj.tagID;
        var myGroup = jsonObj.categorys;
        $display.hide();
        $( '.resource>#resource .catbtn', that ).empty();
        for ( key in tagID ) {
          $( '.resource>#resource .catbtn', that ).append( this.categoryButtonHtml( tagID[ key ] ) );
        }
        if ( $( '#resource .catbtn', that ).height() > 31 ) {
          $( '#resource .more', that ).show();
        }
        //$('#my-resource>.category-btn-list>.my-group', me).empty();
        for ( key in myGroup ) {
          $( '#my-resource>.category-btn-list>.my-group', that ).append( this.groupBtnHtml( myGroup[ key ] ) );
        }

        function myGroupFun() {
          if ( $( '#my-resource .my-group', that ).height() > 31 ) {
            $( '#my-resource .more', that ).show();
          }
        }
        if ( $( '.my-resource', that ).css( 'display' ) != 'none' ) {
          myGroupFun();
        } else {
          $( '.my-resource', that ).show();
          myGroupFun();
          $( '.my-resource', that ).hide();
        }
      }
    };

    function pageInputCheck() {
      var page = $( this ).val() * 1;
      var max = $( this ).parent().find( '.maxPage' ).text() * 1;
      if ( !page ) {
        $( this ).val( '' );
      } else {
        if ( page > max ) {
          $( this ).val( max );
        }
      }
    }

    // 分页相关 跳转
    $( '.pageControl', that ).on( 'click', '.goPage', function() {
      var me = $( this );
      var page = me.parent().find( '.inp_page' ).val() * 1;
      var max = $( this ).parent().find( '.maxPage' ).text() * 1;
      var currentPage = $( this ).parent().find( '.current_page' ).text() * 1;
      if ( currentPage === page ) return;
      if ( page ) {
        var currentIndex = ArticleChooseHtmlBuild.options.tabIndex;
        if ( page >= max ) {
          me.parent().find( '.next' ).prop( 'disabled', 'disabled' );
        } else {
          me.parent().find( '.next' ).removeAttr( 'disabled' );
        }
        if ( page > 1 ) {
          me.parent().find( '.prev' ).removeAttr( 'disabled', 'disabled' );
        } else {
          me.parent().find( '.prev' ).prop( 'disabled' );
        }

        articleOptions[ currentIndex ].setAttrbute( {
          p: page,
          page_num: page
        } );
      } else {
        $( this ).val( '' );
        ShowTitleMessage.showWarning( '请输入正确的页码', showTime );
      }
    } ).on( {
      change: pageInputCheck,
      keyup: pageInputCheck
    }, '.inp_page' ).on( 'click', '.next', function() {
      var me = $( this );
      var currentObj = articleOptions[ ArticleChooseHtmlBuild.options.tabIndex ];
      var page = ( currentObj.param.p || currentObj.param.page_num ) + 1;
      var max = me.parent().find( '.maxPage' ).text() * 1;
      if ( page >= max ) {
        me.prop( 'disabled', 'disabled' );
      }
      currentObj.setAttrbute( {
        p: page,
        page_num: page
      }, function() {
        me.parent().find( '.prev' ).removeAttr( 'disabled' );
      } );

    } ).on( 'click', '.prev', function() {

      var me = $( this ).parent();
      var currentObj = articleOptions[ ArticleChooseHtmlBuild.options.tabIndex ];
      var page = ( currentObj.param.p || currentObj.param.page_num ) - 1;
      if ( page <= 1 ) {
        $( this ).prop( 'disabled', 'disabled' );
      }
      currentObj.setAttrbute( {
        p: page,
        page_num: page
      }, function() {
        me.find( '.next' ).removeAttr( 'disabled' );
      } );
    } );

    that.show();
    $( '[event-columns="article-choose"]', that ).bwColumns( [ '推荐', '我的文章', '我的收藏' ], function( index ) {
      ArticleChooseHtmlBuild.options.tabIndex = index.index();
      $( ".modal-body>div", that ).eq( index.index() ).show().siblings().hide();
      if ( index.index() === 1 ) {
        if ( !$( '.my-resource .arti_content [article-id]', that ).length ) {
          articleOptions[ index.index() ].setAttrbute();
        }
        if ( !this.articleGroupLoad ) {
          this.articleGroupLoad = !0;
          ArticleChooseHtmlBuild.articleGroup();
        }
      } else if ( index.index() === 2 ) {
        if ( !this.collectionGroupLoad ) {
          this.collectionGroupLoad = !0;
          ArticleChooseHtmlBuild.collectionGroup();
        }
        if ( !$( '.my-collection .collection [article-id]', that ).length ) {
          articleOptions[ index.index() ].setAttrbute();
        }
      }
    } );
    that.hide();
    // 搜索文章
    $( '.search_btn', that ).click( function() {
      var thisVal = $( '.search_input', that ).val();
      articleOptions[ ArticleChooseHtmlBuild.options.tabIndex ].setAttrbute( {
        key: thisVal,
        keyword: thisVal,
        p: 1,
        page_num: 1
      } );
    } );
    // 选择文章确认
    $( '.article-btn', that ).click( function() {
      var tabIndex = ArticleChooseHtmlBuild.options.tabIndex;
      var selectedObj = null;
      if ( tabIndex == 0 ) {
        selectedObj = $( '.recommend>.res-det>.selected', that );
      } else if ( tabIndex == 1 ) {
        selectedObj = $( '.my-resource>.res-det>.selected', that );
      } else if ( tabIndex == 2 ) {
        selectedObj = $( '.my-collection>.res-det>.selected', that );
      }

      if ( !selectedObj.attr( 'article-ID' ) ) {
        ShowTitleMessage.showWarning( "请先选择一篇文章", showTime );
        return;
      }
      that.modal( 'hide' );
      if ( $.isFunction( articleChooseCallback ) ) {
        articleChooseCallback.call( that, selectedObj.attr( 'article-ID' ), selectedObj.prop( 'outerHTML' ) );
      }
    } );

    // 模态框弹出
    that.on( 'show.bs.modal', function() {
      $( this ).show();

      if ( !$( '.recommend .div-resource [article-id]', this ).length ) {
        articleOptions[ 0 ].setAttrbute();
      }
    } );

    // 我的素材分组选择
    $( '#my-resource', that ).on( 'click', '.my-group button', function() {
      ArticleChooseHtmlBuild.options.myResourcePageNo = 1;
      var group_select;
      if ( $( this ).hasClass( 'category_select' ) ) {
        $( this ).removeClass( 'category_select' );
        group_select = '';
      } else {
        $( this ).addClass( 'category_select' ).siblings().removeClass( 'category_select' );
        group_select = $( this ).attr( 'groupid' ) || '';
      }
      var more = $( this ).parents( '.group_list' ).find( '.more' );
      if ( more.attr( 'status' ) === '1' ) {
        more.trigger( 'click' );
      }

      articleOptions[ 1 ].setAttrbute( {
        page_num: 1,
        group_select: group_select
      } );

    } ).on( 'change', '#select_type', function() {
      // 我的素材原创和收藏的类型切换
      articleOptions[ 1 ].setAttrbute( {
        page_num: 1,
        select_type: $( '#select_type' ).val(),
        group_select: ''
      } );
      $( '#my-resource .my-group button' ).removeClass( 'category_select' );
    } );

    // 我的收藏分组选择
    $( '#my-collection' ).on( 'click', '.my-group [groupid]', function() {

      var group_select;
      if ( $( this ).hasClass( 'category_select' ) ) {
        $( this ).removeClass( 'category_select' );
        group_select = '';
      } else {
        $( this ).addClass( 'category_select' ).siblings().removeClass( 'category_select' );
        group_select = $( this ).attr( 'groupid' ) || '';
      }
      var more = $( this ).parents( '.group_list' ).find( '.more' );
      if ( more.attr( 'status' ) === '1' ) {
        more.trigger( 'click' );
      }
      articleOptions[ 2 ].setAttrbute( {
        p: 1,
        cgid: group_select
      } );

    } ).on( 'change', '#collection_select_type', function() {

      articleOptions[ 2 ].setAttrbute( {
        p: 1,
        cgid: $( '.my-group [groupid].category_select', $( this ).parents( '#my-collection' ) ).attr( 'groupid' ) || '',
        source: $( '#collection_release' ).val(),
        cs: $( this ).val()
      } );

    } ).on( 'change', '#collection_release', function() {

      articleOptions[ 2 ].setAttrbute( {
        p: 1,
        cgid: $( '.my-group [groupid].category_select', $( this ).parents( '#my-collection' ) ).attr( 'groupid' ) || '',
        source: $( this ).val(),
        cs: $( '#collection_select_type' ).val()
      } );
    } );

    // 领域切换
    $( "#resource>.category-btn-list>.catbtn", that ).on( "click", "button", function() {
      ArticleChooseHtmlBuild.options.resourcePageNo = 1;
      $( ".resource-btn-group>.all", that ).removeClass( 'category_select' );
      $( this ).addClass( 'category_select' ).siblings().removeClass( 'category_select' );
      ArticleChooseHtmlBuild.resourceEmpty().resourceDetailsHtml( $( this ).attr( 'tagsid' ) );
    } );

    // 全网
    $( "#resource>.all", that ).on( "click", function() {
      ArticleChooseHtmlBuild.options.resourcePageNo = 1;
      $( this ).addClass( 'category_select' );
      $( ".category-btn-list>.catbtn>button", that ).removeClass( 'category_select' );
      ArticleChooseHtmlBuild.resourceEmpty().resourceDetailsHtml( '000' );
    } );

    /**
     * 选择分类选择
     */
    $( '.body-content', that ).on( 'click', '[article-id] .icon-doSelect', function( e ) {
      e.stopPropagation();
      $( this ).parents( '[article-id]' ).addClass( "selected" ).siblings().removeClass( 'selected' );
    } ).on( 'click', '.prevArticle', function( e ) {
      e.stopPropagation();
    } ).on( 'click', '.filter', function() {
      $( this ).find( '.icon-doSelect' ).trigger( 'click' );
    } ).on( 'click', '[status].more', function() {
      ArticleChooseHtmlBuild.showMoreBtn( $( this ).prev( '.category-btn-list' ), this );
    } );
  }

} );
